package com.lx.api;

import com.lx.api.request.DishPrintPlanObject;
import com.lx.api.request.PrintTaskResult;
import com.lx.api.request.TablePrintPlanObject;
import com.lx.api.response.*;
import com.lx.model.PrintBillFormat;
import com.lx.model.PrintKitchenFormat;
import com.lx.model.PrintPlan;
import com.lx.model.PrintSystemParam;
import com.lx.service.PrintTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value ="api")
public class PrintController extends BaseRestController {

    @Autowired
    private PrintTaskService printTaskService;

    @RequestMapping(value = "/printTask/{shopId}",method = RequestMethod.GET)
    public Object  getPrintTask(@PathVariable("shopId") Long shopId)throws Exception{
        PrintTaskObject object = new PrintTaskObject();
        List<PrintTaskInfo> taskInfos = printTaskService.selectPrintTask(shopId);
        if (taskInfos!=null&&taskInfos.size()>0){
            object.setTotalTask(taskInfos.size());
            object.setPrintTaskInfos(taskInfos);
        }
        return object;
    }

    @RequestMapping(value = "/printTask",method = RequestMethod.POST)
    public Object savePrintTask(@RequestBody PrintTaskResult result)throws Exception{
        printTaskService.savePrintTaskStatus(result.getTaskId(),result.getStatus());
        return null;
    }
}
